File processing method and storage device

ABSTRACT

A file processing method and a storage device are disclosed. In the method, a storage device receives T files that are to be stored in the RAID, and determines a sequence number of a check block in a stripe of the RAID. The storage device repeatedly obtains a data block of the K th  file in the T files as the K th  data block in the stripe, where a value of K progressively increases from 1 to T, and the value of K is not equal to the sequence number of the check block in the stripe. After computing the check block according to data blocks, the storage device writes, into the T disks, the data blocks and the obtained check block in the stripe. By using the foregoing method, one file can be written into one disk of the RAID while ensuring security of file storage.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2013/081172, filed on Aug. 9, 2013, which is hereby incorporatedby reference in its entirety.

TECHNICAL FIELD

The present invention relates to the field of communicationstechnologies, and in particular, to a file processing method and astorage device.

BACKGROUND

A redundant array of independent disks (RAID), also referred to as aredundant array of inexpensive disks (RAID), is referred to as a diskarray for short. A principle of the redundant array of independent disksis to combine a plurality of relatively inexpensive hard disks to form ahard disk array group, so as to provide performance that reaches or evenexceeds performance of a pricy hard disk with a huge capacity, andimprove data security in combination with a design of distributed dataarrangement. According to a different version that is selected, comparedwith a single hard disk, the RAID can increase a storage capacity, andcan also improve data integration and a data error tolerance capability.In addition, for a computer, a disk array looks like an independent harddisk or a logical storage unit.

In an archiving scenario, a large number of files need to be archived.Therefore, in the prior art, a RAID is generally used to store archivedfiles. In addition, to improve data security, a RAID with a checkfunction, for example, in a form of a RAID 3, a RAID 4, a RAID 5, or aRAID 6, is generally used to store archived files. In the prior art, toimprove a data access speed, a file is generally divided into severaldata blocks. A stripe, which includes a plurality of data blocksbelonging to one file and check data, is written into a plurality ofdisks that form the RAID. Because archived files are less frequentlyaccessed, in order to achieve a purpose of energy-saving, disks in astorage system are generally in a sleeping or power-off state afterfiles are archived. When a certain archived file needs to be accessed,the plurality of disks in which data blocks of the file are stored needto be waken up or powered on, so as to read the file.

SUMMARY

Embodiments of the present invention provide a file processing methodand a storage device, which can store one file in one storage apparatusof a RAID while ensuring security of file storage, and can achieve aneffect of energy saving.

According to a first aspect, an embodiment of the present inventionprovides a file processing method performed by a storage device forstoring a file in a redundant array of independent disks (RAID),including:

receiving T files that are to be stored in the RAID, where a value ofthe T is no less than 3, and the value of the T is equal to the numberof disks that form the RAID;

determining a sequence number of a check block in a stripe of the RAID;

repeatedly obtaining a data block, to be written into a disk, of theK^(th) file in the T files as the K^(th) data block in the stripe, wherea value of K progressively increases from 1 to T, and the value of K isnot equal to the sequence number of the check block in the stripe;

computing the check block in the stripe according to data blocks in thestripe; and

writing, into the T disks, the data blocks in the stripe and theobtained check block in the stripe, wherein each block is written intoone disk.

In a first possible implementation manner of the first aspect, the fileprocessing method further includes:

when the K^(th) file has no data block to be written into the RAID,determining whether other files except the T files are received;

if the other files are received, selecting a file from the receivedother files; and

using a data block, to be written into a disk, in the selected file asthe K^(th) data block in the stripe.

With reference to the first aspect, in a second possible implementationmanner of the first aspect, the method further includes:

when the K^(th) file has no data block to be written into a disk, ifother files except the T files are not received, filling the K^(th) datablock in the stripe with 0s.

With reference to the first aspect or any one of the first to the secondpossible implementation manners of the first aspect, in a third possibleimplementation manner, the method further includes:

receiving an access request of a host, where the access request is usedto read a file stored in the RAID, and the access request carries alogical address of the file that needs to be accessed;

querying, according to the logical address, a physical address in whicha data block of the file is stored;

determining, according to the physical address, one disk in which thefile is stored; and

returning, to the host, the data block of the file stored in the disk.

According to a second aspect, an embodiment of the present inventionprovides a method performed by a storage device for storing a file in aredundant array of independent disks (RAID), where the RAID includes Ddata disks and P independent check disks, a value of the D is no lessthan 2, and a value of the P is no less than 1; and the method includes:

receiving D files that are to be stored in the RAID;

repeatedly obtaining a data block, to be written into a data disk, ofthe K^(th) file in the D files as a data block that is in a stripe ofthe RAID and is to be stored in the K^(th) data disk, where a value of Kprogressively increases from 1 to D;

computing P check blocks in the stripe according to the obtained D datablocks; and

writing the D data blocks into the D data disks, and writing the P checkblocks into the P independent check disks, wherein each block is writteninto one disk.

In a first possible implementation manner of the second aspect, themethod further includes:

when the K^(th) file has no data block to be written into a data disk,determining whether other files except the D files are received;

if the other files are received, selecting a file from the receivedother files; and

using a data block, to be written into a disk, in the selected file as adata block that is in the stripe and is to be stored in the K^(th) datadisk.

With reference to the second aspect, in a second possible implementationmanner of the second aspect, the method further includes:

when the K^(th) file has no data block to be written into a data disk,if other files except the D files are not received, filling the datablock that is in the stripe and is to be stored in the K^(th) data diskwith 0s.

With reference to the second aspect or any one of the first to thesecond possible implementation manners of the second aspect, in a thirdpossible implementation manner, the method further includes:

receiving an access request of a host, where the access request is usedto read a file stored in the RAID, and the access request carries alogical address of the file that needs to be accessed;

querying, according to the logical address, a physical address in whicha data block of the file is stored;

determining, according to the physical address, one disk in which thefile is stored; and

returning, to the host, the data block of the file stored in the disk.

According to a third aspect, an embodiment of the present inventionprovides a storage device, including:

a redundant array of independent disks RAID, configured to store a file,and the RAID includes T disks, where a value of the T is no less than 3;a communication interface, configured to communicate with a host and theRAID; and

-   -   a processor, configured to receive T files that are to be stored        in the RAID;    -   determine a sequence number of a check block in a stripe of the        RAID;    -   repeatedly obtain a data block, to be written into a disk, of        the K^(th) file in the T files as the K^(th) data block in the        stripe, where a value of K progressively increases from 1 to T,        and the value of K is not equal to the sequence number of the        check block in the stripe;

compute the check block in the stripe according to data blocks in thestripe; and

-   -   write, into the T disks, the data blocks in the stripe and the        obtained check block in the stripe, wherein each block is        written into one disk.

In a first possible implementation manner of the third aspect, theprocessor is further configured to:

when the K^(th) file has no data block to be written into a disk,determine whether other files except the T files are received;

if the other files are received, select a file from the received otherfiles; and

use a data block, to be written into a disk, in the selected file as theK^(th) data block in the stripe.

With reference to the third aspect, in a second possible implementationmanner of the third aspect, the processor is further configured to:

when the K^(th) file has no data block to be written into a disk, ifother files except the T files are not received, fill the K^(th) datablock in the stripe with 0s.

With reference to the third aspect or any one of the first to the secondpossible implementation manners of the third aspect, in a third possibleimplementation manner, the processor is further configured to:

receive an access request of a host, where the access request is used toread a file stored in the RAID, and the access request carries a logicaladdress of the file that needs to be accessed;

query, according to the logical address, a physical address in which adata block of the file is stored;

determine, according to the physical address, one disk in which the fileis stored; and

return, to the host, the data block of the file stored in the disk.

According to a fourth aspect, an embodiment of the present inventionprovides a storage device, including:

a redundant array of independent disks RAID is configured to store afile, where the RAID comprises D data disks and P independent checkdisks, a value of the D is no less than 2, and a value of the P is noless than 1;

a communication interface, configured to communicate with a host and theRAID; and

a processor, configured to receive D files that are to be stored in theRAID;

repeatedly obtain a data block, to be written into a data disk, of theK^(th) file in the D files as a data block that is in a stripe of theRAID and is to be stored in the K^(th) data disk, where a value of Kprogressively increases from 1 to D;

compute P check blocks in the stripe according to the obtained D datablocks; and

write the D data blocks into the D data disks, and write the P checkblocks into the P independent check disks, wherein each block is writteninto one disk.

In a first possible implementation manner of the fourth aspect, theprocessor is further configured to:

when the K^(th) file has no data block to be written into a data disk,determine whether other files except the D files are received;

if the other files are received, select a file from the received otherfiles; and

use a data block, to be written into a disk, in the selected file as adata block that is in the stripe and is to be stored in the K^(th) datadisk.

With reference to the fourth aspect, in a second possible implementationmanner of the fourth aspect, the processor is further configured to:

when the K^(th) file has no data block to be written into a data disk,if other files except the D files are not received, fill the data blockthat is in the stripe and is to be stored in the K^(th) data disk with0s.

With reference to the fourth aspect or any one of the first to thesecond possible implementation manners of the fourth aspect, in a thirdpossible implementation manner, the processor is further configured to:

receive an access request of a host, where the access request is used toread a file stored in the RAID, and the access request carries a logicaladdress of the file that needs to be accessed;

query, according to the logical address, a physical address in which adata block of the file is stored;

determine, according to the physical address, one disk in which the fileis stored; and

return, to the host, the data block of the file stored in the disk.

According to a fifth aspect, an embodiment of the present inventionprovides a computer program product, including a computer readablestorage medium that stores program code, where an instruction includedin the program code is used to execute the method according to the firstaspect and any one of possible implementation manners of the firstaspect.

According to a sixth aspect, an embodiment of the present inventionprovides a computer program product, including a computer readablestorage medium that stores program code, where an instruction includedin the program code is used to execute the method according to thesecond aspect and any one of possible implementation manners of thesecond aspect.

According to the file processing method provided in the embodiments ofthe present invention, a storage device determines a sequence number ofa check block in a stripe of a RAID. A data block, to be written into astorage apparatus, of the K^(th) file in received T files is obtained tobe the K^(th) data block in the stripe, where a value of K is not equalto the sequence number of the check block in the stripe. After obtainingdata blocks from the files, the storage device obtains, by computing,the check block in the stripe according to the obtained data blocks inthe stripe, and writes the data blocks and the check block in the stripeinto disks that form the RAID. Before the storage device write the filesinto disks, data blocks of one file are correspond to same position instripes, thus the data blocks of the one file are correspond to one diskin the RAID. Therefore, the storage device can write all data blocks ofthe one file into the one disk. In an application scenario of archiving,when a file, which is stored in the RAID by using the method of theembodiments of the present invention needs to be accessed, not all disksin the RAID need to be waken up or powered on, but only one disk inwhich the file is stored needs to be operated, so as to achieve asignificant effect of energy saving.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention or in the prior art more clearly, the following brieflyintroduces the accompanying drawings required for describing theembodiments. Apparently, the accompanying drawings in the followingdescription show merely some embodiments of the present invention.

FIG. 1 is a diagram of an application scenario of a file processingmethod according to an embodiment of the present invention;

FIG. 2 is a schematic structural diagram of a storage device accordingto an embodiment of the present invention;

FIG. 3 is a flowchart of a file processing method according to anembodiment of the present invention;

FIG. 4A is a schematic diagram of positions according to an embodimentof the present invention;

FIG. 4B is a schematic diagram of dividing data blocks in a fileaccording to an embodiment of the present invention;

FIG. 4C is a schematic diagram of a file storage structure according toan embodiment of the present invention;

FIG. 5 is a flowchart of another file processing method according to anembodiment of the present invention;

FIG. 6A is a flowchart of still another file processing method accordingto an embodiment of the present invention;

FIG. 6B is a schematic diagram of another file storage structureaccording to an embodiment of the present invention;

FIG. 7 is a flowchart of yet another file processing method according toan embodiment of the present invention; and

FIG. 8 is a schematic flowchart of a file reading method according to anembodiment of the present invention.

DESCRIPTION OF EMBODIMENTS

To make a person skilled in the art understand the technical solutionsin the present invention better, the following clearly describes thetechnical solutions in the embodiments of the present invention withreference to the accompanying drawings in the embodiments of the presentinvention. Apparently, the described embodiments are merely a partrather than all of the embodiments of the present invention.

As shown in FIG. 1, FIG. 1 is a diagram of an application scenarioaccording to an embodiment of the present invention. In the applicationscenario shown in FIG. 1, a storage system includes a host 100, aconnection device 105, and a storage device 110.

The host 100 may include any computing device known in the prior art,such as a server, a desktop computer, or an application server. Anoperating system and other application programs are installed on thehost 100, and there may be multiple hosts 100.

The connection device 105 may include any interface between a storagedevice and a host that is known in the prior art, for example, a fiberswitch or another existing switch.

The storage device 110 may include a storage device known in the priorart, such as a storage array, a Just a Bunch Of Disks (JBOD), or one ormore interconnected disk drives of a direct access storage device(DASD), where the direct access storage device may include a tapelibrary or a tape storage device with one or more storage units.

FIG. 2 is a schematic structural diagram of a storage device 110according to an embodiment of the present invention, and the storagedevice shown in FIG. 2 is a storage array. As shown in FIG. 2, thestorage device 110 may include a controller 115 and a disk array 125,where the disk array herein refers to a redundant array of independentdisks (RAID). There may be multiple disk arrays 125, and the disk array125 is formed by multiple disks 130. Communication between the diskarray 125 and the controller 115 may be performed by using acommunications protocol, such as the small computer system interface(SCSI) protocol, which is not limited herein.

The controller 115 is a “brain” of the storage device 110. Thecontroller 115 mainly includes a processor 118, a cache 120, a memory122, a communication bus (bus for short) 126, and a communicationinterface 128. The processor 118, the cache 120, the memory 122, and thecommunication interface 128 communicate with each other by using thecommunication bus 126.

The communication interface 128 is configured to communicate with thehost 100 and the disk array 125.

The memory 122 is configured to store a program 124. The memory 122 mayinclude a high-speed RAM memory, or may include a non-volatile memory(non-volatile memory), for example, at least one disk memory. It can beunderstood that the memory 122 may be any non-transitorymachine-readable medium which is capable of storing program code, suchas a random-access memory (RAM), a magnetic disk, a hard disk, anoptical disc, a solid state disk (SSD), or a non-volatile memory.

The program 124 may include program code, where the program codeincludes a computer operation instruction.

The cache 120 is configured to buffer data received from the host 100and buffer data read from the disk array 125, so as to improveperformance and reliability of the array. The cache 120 may be anynon-transitory machine-readable medium which is capable of storing data,such as a RAM, a ROM, a flash memory, or a solid state disk (SSD), whichis not limited herein.

The processor 118 may be a central processing unit CPU, or anapplication specific integrated circuit ASIC, or be configured as one ormore integrated circuits that implement the embodiment of the presentinvention. An operating system and other software programs are installedin the processor 118. Different software programs may be considered as aprocessing module with different functions, for example, processing aninput/output (I/O) request for a disk 130, performing other processingon data in the disk, or modifying metadata stored in the storage device.Therefore, the controller 115 can implement an IO operation and a RAIDmanagement function, and can also provide various data managementfunctions, such as snapshotting, mirroring, and copying. In theembodiment of the present invention, the processor 118 is configured toexecute the program 124, and may specifically perform related steps ofthe following method embodiments.

The disk array 125 is configured to store data. In the embodiment of thepresent invention, an organization form of the disk array 125 is a RAIDmanner with a check function, for example, a RAID 3, RAID 4, RAID 5, orRAID 6, which is not limited herein.

With reference to FIG. 1, any storage device 110 may receive, through aconnection device 105, multiple files sent by one or more hosts 100,divide the received multiple files into multiple data blocks, and storethe data blocks in multiple disks 130 that form the disk array 125. Anystorage device 110 may also receive a file read request sent by any host100, and return a data block of the file stored in the disk 130 to thehost 100 according to the file read request.

It should be noted that the disk 130 is merely an example of storageapparatuses that form the disk array 125, and in an actual application,there may be an implementation manner that a disk array is formedbetween cabinets including multiple disks. Therefore, the storageapparatus in the embodiment of the present invention may include anyapparatus such as a magnetic disk, a solid state drives (SSD), a server,or a cabinet formed of multiple magnetic disks, which is not limitedherein.

FIG. 3 is a flowchart of a file processing method according to anembodiment of the present invention. The method may be performed by thecontroller 115 of the storage device 110 shown in FIG. 2, and the methodmay be applied to a file archiving scenario. The method is mainlyapplied to a RAID organization form with a distributed check function,where the RAID organization form with a distributed check functionincludes but is not limited to a RAID 5 and a RAID 6. As shown in FIG.3, the method includes:

In step 300, the storage device 110 receives T files that are to bestored in a RAID, where a value of the T is a natural number no lessthan 3, and the value of the T is equal to the number of storageapparatuses that form the RAID.

In the embodiment of the present invention, the controller 115 of thestorage device 110 may receive a file storage request sent by one ormore hosts 100. The file storage request is used to request to store afile in the RAID, and the file storage request may include one or morefiles to be stored.

With reference to FIG. 2, the storage device 110 may include multipleRAIDs, and each RAID should include no less than 3 disks. It should beunderstood that multiple RAIDs included in one storage device 110 mayhave same organization form. For example, all RAIDs included in thestorage device 110 are in an organization form of the RAID 5. Certainly,the organization forms of the multiple RAIDs included in one storagedevice 110 may also be different. For example, if the storage device 110includes two RAIDs, one RAID may be the RAID 3, and the other RAID maybe the RAID 5, which is not limited herein. In the embodiment of thepresent invention, one RAID in the storage device 110 is used as anexample for description.

It can be understood that the storage device 110 may process T fileswhen receive T files. The storage device 110 may also buffer receivedmultiple files in the cache 120, and then randomly select T files fromthe received multiple files for processing when storage time reaches. Avalue of T is equal to the number of disks in the RAID. For example, ifthe RAID includes 4 disks, the storage device 110 may process 4 files atthe same time.

The storage time is a preset time for writing files into disks that formthe RAID. For example, it may be specified that storage is performedonce an hour, and then the storage time is 1 hour. The storage time maybe determined according to an actual situation such as a volume of datathat needs to be written into disks. Storage may be performed once aday, or storage may be performed every 10 minutes, which is not limitedherein.

In step 305, the storage device 110 determines a sequence number of acheck block in a stripe of the RAID. A stripe described in theembodiment of the present invention indicates a set of data blocks thatare concurrently written into each of storage apparatuses that form theRAID, where a size of each data block in the stripe is the same, anddata blocks of a stripe are located in each storage apparatus with sameoffset. A data block in the stripe is also referred to as a strip, andthe strip is a continuous address block in an extent. In a disk array,the controller generally uses a strip to map a block address of avirtual disk to a block address of a member disk. A strip is alsoreferred to as a stripe element.

In a specific operation, the storage device 110 may determine a sequencenumber of a check block in a stripe according to an organization form ofthe RAID. The sequence number herein indicates a position number of acheck block in the stripe. In the embodiment of the present invention, aposition number in a stripe starts from 1 and progressively increases by1 successively. For example, as shown in FIG. 4A, a stripe 1 includes acheck block 1 of a data block 1, a data block 2 and a data block 3. Asequence number of the data block 1 is 1, a sequence number of the datablock 2 is 2, and a sequence number of the data block 3 is 3. The checkblock 1 is located in the 4^(th) position of the stripe 1, so that asequence number of the check block 1 is 4. A stripe 2 includes a datablock 4, a data block 5, a check block 2, and a data block 6, where thecheck block 2 is located in the 3^(rd) position of the stripe 2, so thata sequence number of the check block 2 is 3. It can be understood that asequence number in a stripe corresponds to a sequence number of a memberdisk in the RAID. For example, if a sequence number of a check block ina stripe is 4, the check bock may be written into the fourth member diskin the RAID.

In a RAID with a distributed check function, how a specific check blockis distributed in a strip may be determined according to an organizationform of the first RAID and a distribution manner of the check block. Forexample, a distribution manner of a check block on a disk in the RAID 5may be left synchronous (backward parity or Left Synchronous), leftasynchronous (backward dynamic or Left Asynchronous), right synchronous(forward parity or Right Synchronous), or right asynchronous (forwarddynamic or Right Asynchronous). “Left” or “right” indicates how checkinformation is distributed, and “synchronous” or “asynchronous”indicates how data is distributed. In an algorithm of “left”, startingfrom the last disk, a check block is moved one disk position in eachstripe in a direction towards the first disk (to be distributedcircularly and repeatedly if necessary). In an algorithm of “right”,starting from the first disk, a check block is moved one disk positionin each stripe in a direction towards the last disk (to be distributedcircularly and repeatedly if necessary). The RAID 6 is added withanother group of check blocks on a basis of the RAID 5.

In step 310, the storage device 110 obtains a data block, to be writteninto a storage apparatus, of the K^(th) file in the T files as theK^(th) data block in the stripe, where a value of K progressivelyincreases from 1 to T, and the value of K is not equal to the sequencenumber of the check block in the stripe.

For example, there are 4 disks in the RAID. If in step 305, the storagedevice 110 determines that a sequence number of the check block in thecurrent stripe is a sequence number of 4 in the stripe 1 shown in FIG.4A, then in step 310, when the storage device 110 processes received 4files F1, F2, F3, and F4, the value of K starts from 1 and progressivelyincreases by 1 successively. It can be understood that the value of Kcannot be greater than T. In addition, a position needs to be reservedfor the check block in the stripe. Therefore, in the embodiment of thepresent invention, the value of K is not equal to the sequence number ofthe check block in the stripe. In other words, the storage device 110may, starting from the 1^(st) file, successively obtain a data block ina corresponding position of the stripe. However, the storage device 110does not obtain a data block from a file corresponding to a value of thesequence number of the check block in the stripe. For example, a datablock of the 1^(st) file F1 is obtained to be the 1^(st) data block inthe stripe 1 (the data block 1 in the stripe 1 shown in FIG. 4A), a datablock of the 2^(nd) file F2 is obtained to be the 2^(nd) data block inthe stripe 1 (the data block 2 in the stripe 1 shown in FIG. 4A), and adata block of the 3^(rd) file F3 is obtained to be the 3^(rd) data blockin the stripe 1 (the data block 3 in the stripe 1 shown in FIG. 4A).Because the value of K is not equal to the sequence number of the checkblock in the stripe, in step 310, the storage device 110 does not obtaina data block of the 4^(th) file F4.

It can be understood that, if in step 305, the storage device 110determines that the sequence number of the check block in the currentstripe is a sequence number of 3 in the stripe 2 shown in FIG. 4A, then,in step 310, a data block of the 1^(st) file F1 may be obtained to bethe 1st data block in the stripe 2 (the data block 4 in the stripe 2shown in FIG. 4A), a data block of the 2^(nd) file F2 may be obtained tobe the 2^(nd) data block in the stripe 2 (the data block 5 in the stripe2 shown in FIG. 4A), and a data block of the 4^(th) file F4 may beobtained to be the 4^(th) data block in the stripe 2 (the data block 6in the stripe 2 shown in FIG. 4A). In this case, the sequence number ofthe check block in the stripe 2 is 3, and therefore, the storage device110 does not obtain a data block of the 3^(rd) file F3.

It should be noted that the number of check blocks in a stripe is notlimited in the embodiment of the present invention. It can be understoodthat if one stripe of the RAID includes one check block, and a sequencenumber of the check block in the stripe is 3, the storage device 110does not obtain a data block of the 3^(rd) file. If one stripe of theRAID includes 2 check blocks, and sequence numbers of the two checkblocks in the stripe are 3 and 4, respectively, the storage device 110does not obtain a data block from the 3^(rd) file and the 4^(th) file.

The data block described in the embodiment of the present inventionindicates a data unit formed by multiple pieces of data. The check blockdescribed in the embodiment of the present invention indicates a dataunit formed by check data. Data blocks obtained from different files areformed into a stripe of the RAID. Therefore, it can be understood thatthe storage device 110 may obtain data blocks from files according to astrip size of the RAID. In other words, a data block size is equal tothe strip size of the RAID. A strip size, sometimes also referred to asa block size, a chunk size, or a granularity, indicates a size of a datablock written into each disk. Generally, a strip size of a RAID isbetween 2 KB to 512 KB (or greater), and a value of the strip size is 2to the power of n, for example, 2 KB, 4 KB, 8 KB, 16 KB, or the like.

It can be understood that in an actual application, a data block may beobtained from a file according to a starting address of the file and astrip size, or the received T files may be divided into data blocksaccording to the strip size of the RAID in advance. When a file isdivided, if a size of a file is less than the strip size, the file maybe obtained to be a data block. If after a file is divided, a size ofremaining data of the file is less than the strip size, the remainingdata of the file is obtained to be a data block. For example, as shownin FIG. 4-B, the controller 115 divides received 4 to-be-stored filesF1-F4 according to the strip size of the RAID. The file F1 is dividedinto 5 data blocks: F1-1, F1-2, F1-3, F1-4, and F1-5. The file F2 isdivided into 3 data blocks: F2-1, F2-2, and F2-3. The file F3 is dividedinto one data block F3-1. The file F4 is divided into 5 data blocks:F4-1, F4-2, F4-3, F4-4, and F4-5. In step 310, the storage device 110may directly obtain a data block, to be written into a disk, of eachfile as a data block in a corresponding position of the stripe. Forexample, when data blocks in the stripe 1 shown in FIG. 4A aredetermined, F1-1 may be obtained to be the data block 1 in the stripe 1,F2-1 may be obtained to be the data block 2 in the stripe 1, and F3-1may be obtained to be the data block 3 in the stripe 1.

It should be noted that when a data block of a file is obtained, anydata block, to be written into disks, of the file may be obtained as adata block in a position corresponding to the file in the stripe. Forexample, if all data blocks in F1 are to be written into disks, any oneof the data blocks F1-1, F1-2, F1-3, F1-4, or F1-5 may be obtained to bethe data block 1 of the stripe 1.

In step 315, the storage device 110 obtains the check block in thestripe according to the data blocks in the stripe. After obtaining thedata blocks in the stripe, the storage device 110 may perform a checkcomputation on the data blocks in the stripe according to a checkalgorithm of the RAID, to obtain the check block in the stripe. Theobtained check block is a check block in the stripe in a positioncorresponding to the sequence number determined in step 305. It can beunderstood that the check algorithm of the RAID includes but is notlimited to a parity check algorithm.

In step 320, the storage device 110 writes, into the T storageapparatuses, the data blocks in the stripe and the obtained check blockin the stripe. Specifically, the storage device 110 may concurrentlywrite, into T disks that form the RAID, the data blocks and the checkblock in the stripe. For example, if F1-1, F2-1, F3-1, and the checkblock 1 form the stripe 1 in FIG. 4A, F1-1, F2-1, F3-1, and the checkblock 1 may be concurrently written into 4 disks that form the RAID,where the check block 1 is obtained by computing according to F1-1,F2-1, and F3-1. A storage structure of the stripe 1 shown in FIG. 4-C isformed.

It can be understood that, after the stripe 1 is written, the storagedevice 110 may continue to obtain data blocks in the stripe 2, andobtain the check block in the stripe 2 according to the obtained datablocks, and concurrently write the data blocks and the check block inthe stripe 2 into disks. A storage structure of the stripe 2 shown inFIG. 4-C is formed. Other stripes are processed by analog until allfiles are stored in disks.

It can be understood that, in the embodiment of the present invention,after a data block of a file is written into a disk, the data block maybe marked as a data block that has been written into a disk, or may bedeleted from the file, so that a data block, to be written into a disk,of the file can be identified when a data block in a next stripe needsto be obtained. In the embodiment of the present invention, a method ofidentifying a data block, to be written into a disk, of a file is notlimited.

It can be known from the foregoing that in the file processing methoddescribed in the embodiments of the present invention, the storagedevice 110 determines a sequence number of a check block in a stripe ofthe RAID. A data block, to be written into a storage apparatus, of theK^(th) file in received T files is obtained to be the K^(th) data blockin the stripe, where a value of K is not equal to the sequence number ofthe check block in the stripe. After obtaining data blocks from thefiles, the storage device 110 obtains, by computing, the check block inthe stripe according to the obtained data blocks in the stripe, andwrite the data blocks and the check block in the stripe into disks thatform the RAID. In this method, before the storage device 110 write thefiles into disks, data blocks of one file are correspond to sameposition in stripes, thus the data blocks of the one file are correspondto one disk in the RAID. Therefore, the storage device 110 can write alldata blocks of the one file into one disk. In an application scenario ofarchiving, when a file, which is stored in the RAID by using the fileprocessing method described in the embodiment of the present invention,needs to be accessed, not all disks in the RAID need to be woken up orpowered on, but only one disk in which the file is stored needs to beoperated, so as to achieve a significant effect of energy saving.

In addition, in the file processing method described in the embodimentof the present invention, data blocks of different files form a stripe,and the storage device 110 writes the stripe into disks. When a certaindata block of a stripe is damaged, the storage device 110 can restorethe damaged data block according to a check block and data blocks ofother files in the stripe. Security of file storage is ensured while afile write efficiency is ensured.

FIG. 5 is a flowchart of another file processing method according to anembodiment of the present invention. The method may be performed by thecontroller 115 of the storage device 110 shown in FIG. 2, and the methodmay be applied to a file archiving scenario. In the embodiment of thepresent invention, a RAID including 4 disks is used as an example fordescription. The following describes FIG. 5 with reference to FIG. 2,FIG. 4B, and FIG. 4C. As shown in FIG. 5, the method includes:

In step 400, the storage device 110 receives T files that are to bestored in a RAID.

In step 405, the storage device 110 determines a sequence number of acheck block in a stripe of the RAID.

Step 400 is similar to step 300 in FIG. 3, and step 405 is similar tostep 305 in FIG. 3. Therefore, reference may be made to relateddescription of step 300 and step 305, and details are not repeatedlydescribed herein.

In step 410, the storage device 110 determines whether the K^(th) fileof the T files includes a data block to be written into a disk. If theK^(th) file includes a data block to be written into a disk, step 415 isperformed; otherwise, step 420 is performed. In a case, if in step 405,the storage device 110 determines that the sequence number of the checkblock in a stripe of the RAID is not 1, an initial value of K may befirst set to 1 in this step. In other words, the storage device 110needs to determine whether the 1^(st) file of the T files includes adata block to be written into a disk. If the 1^(st) file includes a datablock to be written into a disk, step 415 is performed; otherwise, step420 is performed. In another case, if in step 405, the storage device110 determines that the sequence number of the check block in a stripeof the RAID is 1, an initial value of K may be first set to 2 in thisstep. In other words, the storage device 110 needs to determine whetherthe 2^(nd) file includes a data block to be written into a disk. If the2^(nd) file includes a data block to be written into a disk, step 415 isperformed; otherwise, step 420 is performed. In another expressionmanner, if the sequence number of the check block in one stripe is not1, the storage device needs to start to obtain a data block in the onestripe from the 1^(st) file. If the sequence number of the check blockin one stripe is 1, the storage device needs to start to obtain a datablock in the one stripe from the 2^(nd) file.

It can be understood that in the embodiment of the present invention,the storage device 110 may identify a data block that is of a file andhas been written into a disk by marking the data block or by deletingthe data block from the file, so that the storage device 110 canidentify a data block, to be written into a disk, of the file. A methodfor identifying a data block, to be written into a disk, of a file bythe storage device 110 is not limited herein.

In step 415, the storage device 110 obtains a data block, to be writteninto a disk, of the K^(th) file in the T files, as the K^(th) data blockin the stripe, where a value of K is not equal to the sequence number ofthe check block in the stripe. In other words, when the storage device110 obtains data blocks of files, the storage device 110 cannot obtain adata block of a file, where a sequence of the file corresponds to thesequence number of the check block in the stripe, so that a positioncorresponding to the sequence number can be reserved for the check datain the stripe. For specific description of step 415, reference may bemade to related description of step 310 in FIG. 3.

In step 420, the storage device 110 determines whether other filesexcept the T files are received. In an actual application, if thestorage device 110 determines, in step 410, that the K^(th) file of theT files does not include a data block to be written into a disk, itindicates that the K^(th) file has been completely stored in the disk.The storage device 110 needs to further determine whether the otherfiles except the T files are received, where the other files need to bestored in the disks that form the RAID. If the storage device 110receives the other files except the T files, step 423 of the method isperformed; otherwise, step 430 of the method is performed.

For example, as shown in FIG. 4-B and FIG. 4-C, the 3^(rd) file F3, inthe 4 files shown in FIG. 4-B, is relatively small, and F3 is obtainedas a data block F3-1. After the stripe 1, which is formed by data blocksF1-1, F2-1, F3-1, and the check block P1, is written into 4 disks thatform the RAID, when the storage device 110 obtains data blocks of thestripe 3, because the sequence number of the check block P3 in thestripe 3 is 2, for the stripe 3, a data block, to be written into adisk, of the third file F3 needs to be obtained as the 3^(rd) datablock. Because the data block F3-1 of the file F3 has been written intothe stripe 1, the file F3 does not include a data block to be writteninto a disk. Therefore, the storage device 110 needs to determinewhether other files except the files F1-F4 are received. For example, inthe example shown in FIG. 4-B, the storage device 110 needs to determinewhether the 5^(th) file F5 is received.

In step 423, the storage device 110 selects a file from the other filesexcept the T files. Specifically, the storage device 110 may randomlyselect a file from the other files.

In step 425, the storage device 110 obtains a data block, to be writteninto a disk, of the selected file as the K^(th) data block in thestripe. In an actual application, in a case, when the K^(th) file of theT files has been written into a disk, if the storage device 110 receivesthe other files, except the T files, that need to be stored in the disksthat form the RAID, the storage device 110 may obtain a data block, tobe written into a disk, of any one file of the other files as the K^(th)data block in the stripe. In this manner, the storage device 110 maywrite a stripe, which includes the data block that is of any one file ofthe received other files and data blocks, to be written into a disk, ofother files in the T files, into the disk. For example, in the foregoingexample, if the storage device 110 receives the 5^(th) file F5 that isto be stored in the RAID, the storage device 110 may obtain the datablock F5-1, to be written into a disk, of the file F5 as a data block ina position with a sequence number of 3 in the stripe 3. Then step 435 isperformed to form the stripe 3 including the data block F5-1 and datablocks in the files F1 and F4. For details, reference may be made to astructure of the stripe 3 shown in FIG. 4-C.

In step 430, the storage device 110 fills the K^(th) data block in thestripe with 0s. In an actual application, in another case, if thestorage device 110 determines, in step 420, that the other files, exceptthe T files, that need to be stored in the RAID are not received, thestorage device 110 may, in step 430, fill the K^(th) data block in thestripe with 0s, which is used to indicate that the data block is notused.

In step 435, the storage device 110 determines whether the value of K isgreater than T. If the value of K is not greater than T, step 440 isperformed; otherwise, step 445 is performed.

In step 440, the storage device 110 sets K=K+1. In other words, thestorage device 110 sets the value of the variable K to a value of K+1,and returns to step 410 to start to obtain a next data block in thestripe. By performing step 410, step 415, step 435, and step 440, thestorage device 110 may obtain data blocks of other files except a file,where a sequence of the file corresponds to the sequence number of thecheck block in the stripe, so as to obtain all data blocks in thestripe.

In step 445, the storage device 110 obtains the check block in thestripe according to the data blocks in the stripe. For specificdescription of this step, reference may be made to related descriptionof step 315 in FIG. 3.

In step 450, the storage device 110 writes, into the T disks, the datablocks in the stripe and the obtained check block in the stripe. Forspecific description of this step, reference may be made to relateddescription of step 320 in FIG. 3.

In step 455, the storage device 110 determines whether a file that hasnot been completely written into a disk of the RAID exists. If a file inthe T files has not been completely written into a disk, in other words,if the file is not yet stored in the disk completely, go back to step405. The storage device 110 continues to determine a sequence number ofthe check block in the next stripe, and obtain data blocks in the nextstripe, so as to write the data blocks and the check block in the nextstripe into the disks. If in step 455, the storage device 110 determinesthat all files that are to be stored in the RAID have been storedcompletely, step 460 of the method is performed to end the storageprocedure. By using the file processing method shown in FIG. 5, afterfiles are stored in the RAID, one file may be stored in one disk of theRAID. A specific storage structure may be shown in FIG. 4-C. It can beclearly understood by a person skilled in the art that, for the purposeof convenient and brief description, for description of some steps ofthe embodiment in FIG. 5, reference may be made to specific descriptionof a corresponding process in the embodiment shown in FIG. 3.

In another case, when an organization form of the RAID is a RAID with anindependent check disk, for example, when the RAID is a RAID 3 or a RAID4, the controller 115 may perform file storage according to a methodshown in FIG. 6. In the embodiment of the present invention, a RAIDincluding 4 member disks is used as an example for description. Theorganization form of the RAID is the RAID 3, where the RAID includes 3data disks and 1 independent check disk. A person skilled in the art canknow that a data disk is a member disk, used for storing a data block,in an array. An independent check disk is a member disk, specially usedfor storing a check block, in the array. The following describes FIG. 6with reference to FIG. 2, FIG. 4B, and FIG. 6B. As shown in FIG. 6A, themethod includes:

In step 600, the storage device 110 receives D files that are to bestored in a RAID. A value of D is equal to the number of data disks inthe RAID. For example, in the RAID including 4 member disks as describedabove, if the organization form of the RAID is the RAID 3, the number ofdata disks in the RAID is 3, and the number of independent check disksis 1.

It can be understood that the storage device 110 may process the D fileswhen receive D files. The storage device 110 may also buffer receivedmultiple files in the cache 120, and then randomly select D files fromthe received multiple files for processing when storage time reaches.For example, as shown in FIG. 4-B, the storage device 110 may select 3files F1-F3 from 4 files F1, F2, F3, and F4, which are received and areto be stored in the RAID, for processing.

In step 605, the storage device 110 obtains a data block, to be writteninto a data storage apparatus, of the K^(th) file in the D files as adata block that is in a stripe of the RAID and is to be stored in theK^(th) data storage apparatus, where a value of K progressivelyincreases from 1 to D.

Because the organization form of the RAID in the embodiment of thepresent invention is a RAID with an independent check disk, in thisstep, when obtaining data blocks in the stripe, the storage device 110needs to reserve a position for a check block to be written into theindependent check disk. The storage device 110 may use a data block, tobe written into a data disk, of the K^(th) file as the data block thatis in the stripe and is to be stored in the K^(th) data disk. Forexample, in the RAID shown in FIG. 6B, member disks D1, D2, and D3 aredata disks, and a member disk D4 is an independent check disk. Whenobtaining data blocks of the stripe, the storage device 110 first setsan initial value of K to 1, and then after obtaining one data block,makes the value of K progressively increase by 1 successively, where thevalue of K is not greater than D. In this manner, the storage device 110starts to obtain a data block from the 1st file, and then successivelyobtain data blocks of the 2^(nd) and the 3^(rd) files. As shown in FIG.4-B, the storage device 110 may successively use the data block F1-1 inthe 1^(st) file F1 as the data block, which is to be written into the1^(st) data disk D1, in the stripe 1; use the data block F2-1 in the2^(nd) file F2 as the data block, which is to be written into the 2^(nd)data disk D2, in the stripe 1; and use the data block F3-1 in the 3^(rd)file F3 as the data block, which is to be written into the 3^(rd) datadisk D3, in the stripe 1. It should be noted that a position of theindependent check disk in the RAID is not limited in the embodiment ofthe present invention, for example, the member disk D3 may be used asthe independent check disk, and the member disk D4 may be used as the3^(rd) data disk in the RAID.

In step 610, the storage device 110 obtains P check blocks in the stripeaccording to the obtained D data blocks. For example, after the threedata blocks F1-1, F2-1, and F3-1 in the stripe 1 in FIG. 6B areobtained, a check computation may be performed on the three data blocksin the stripe 1 according to a check algorithm of the RAID, to obtainthe check block P1 of the stripe 1. It should be noted that in the RAIDwith an independent check disk, the number of check blocks in the stripeis related to a specific organization form of the RAID. For example, theRAID 3 has one independent check disk, and then one stripe has one checkblock. The RAID 4 has two independent check disks, and then one stripehas two check blocks. In the embodiment of the present invention,neither is the organization form of the RAID specifically limited, noris the number of check blocks in the stripe limited. In addition, thecheck algorithm in the embodiment of the present invention includes butis not limited to a parity check algorithm.

In step 615, the storage device 110 writes the D data blocks into the Ddata storage apparatuses, and writes the P check blocks into the Pindependent check storage apparatuses. For example, the storage device110 may concurrently write the 3 data blocks and 1 check block in thestripe 1 into the member disks of the RAID. A person skilled in the artmay know that when data blocks and a check block in a stripe are writteninto member disks, in the RAID with an independent check disk, datablocks need to be written into data disks, and the check block in thestripe needs to be written into the independent check disk. After datais written into disks, a storage structure of the stripe 1 shown in FIG.6B may be formed.

In the embodiment shown in FIG. 6, the storage device 110 uses a datablock, to be written into a data disk, of the K^(th) file in the D filesas a data block that is in a stripe of the RAID and is to be stored inthe K^(th) data disk. In this manner, data blocks of one file correspondto one data disk in the RAID, so that all data blocks belonging to theone file are written into the one data disk. In an application scenarioof archiving, when a file in the RAID needs to be accessed, not alldisks in the RAID need to be woken up, but only one disk in which thefile is stored needs to be woken up, so as to achieve an effect ofenergy saving.

In addition, in the file processing method described in FIG. 6, thestorage device 110 writes a stripe, which includes data blocks ofdifferent files into disks. When a data block in a stripe is damaged,the storage device 110 can restore the damaged data block by using acheck block and data blocks of other files in the stripe, therebyensuring security of file storage while ensuring a file writeefficiency.

FIG. 7 is a flowchart of another file processing method according to anembodiment of the present invention. The method may be performed by thecontroller 115 of the storage device 110 shown in FIG. 2, and the methodmay be applied to a RAID with an independent check disk. In theembodiment of the present invention, a RAID 3 including 4 disks is usedas an example for description. The following describes FIG. 7 withreference to FIG. 2, FIG. 4-B, and FIG. 6B. As shown in FIG. 7, themethod includes:

In step 700, the storage device 110 receives D files that are to bestored in a RAID. For details about this step, reference may be made torelated description of step 600.

In step 705, the storage device 110 determines whether the K^(th) fileof the D files includes a data block to be written into a data disk ofthe RAID. If the K^(th) file includes a data block to be written intothe data disk of the RAID, step 710 of this method is performed;otherwise, step 715 of this method is performed. An initial value of Kis 1. In another expression manner, the storage device 110 needs todetermine whether the 1^(st) file of the D files includes a data blockto be written into the data disk of the RAID. For a specific method fordetermining whether the K^(th) file includes a data block to be writteninto the RAID, reference may be made to related description of step 410in FIG. 5.

In step 710, the storage device 110 obtains a data block, to be writteninto the data disk, of the K^(th) file as a data block that is in astripe of the RAID and is to be stored in the K^(th) data disk. Forspecific description of step 710, reference may be made to relateddescription of step 605 in FIG. 6.

In step 715, the storage device 110 determines whether other filesexcept the D files are received. If the other files except the D filesare received, step 718 of the method is performed; otherwise, step 725of the method is performed. In an actual application, if the storagedevice 110 determines, in step 705, that the K^(th) file of the D filesdoes not include a data block to be written into a disk, it indicatesthat the K^(th) file has been all stored in the disk. In this case, thestorage device 110 needs to further determine whether the other files,which need to be written into the data disks that form the RAID, arereceived. If the storage device 110 receives the other files except theD files, step 718 of the method is performed; otherwise, step 725 of themethod is performed.

For example, among the 3 files F1, F2, and F3 shown in FIG. 4B, the3^(rd) file F3 is relatively small, and F3 is used as the data blockF3-1. In addition, the data block F3-1 has been written into the RAIDshown in FIG. 6B. The storage device 110 currently needs to obtain adata block in the stripe 2, and then the storage device 110 maydetermine that the 3^(rd) file F3 does not include a data block to bewritten into the RAID. In this case, the storage device 110 needs todetermine whether other files except F1-F3 are received, for example,the 4^(th) file F4. If the other files are received, step 718 of thismethod is performed; otherwise, step 725 is performed.

In step 718, the storage device 110 selects a file from the receivedother files except the D files. Specifically, the storage device 110 mayrandomly select a file from the received other files.

In step 720, the storage device 110 uses a data block, to be writteninto a disk, of the selected file as the K^(th) data block in thestripe. For example, in the foregoing example, if the storage device 110receives the 4^(th) file F4 that is to be stored in the RAID, thestorage device 110 may use the data block F4-1, to be written into adisk, of the file F4 as the 3^(rd) data block in the stripe 2. Inanother expression manner, after the storage device 110 stores, in theRAID, all data blocks of the K^(th) file of the D files, the storagedevice 110 starts to store data blocks of the other files except the Dfiles.

In step 725, the storage device 110 fills the K^(th) data block in thestripe with 0s. In another case, when the storage device 110 determines,in step 715, that the other files except the D files are not received,where the other files need to be stored in the RAID, the storage device110 may, in step 725, fill the K^(th) data block in the stripe with 0s,which is used to indicate that the data block is not used.

In step 730, the storage device 110 determines whether the value of K isgreater than D. If the value of K is not greater than D, step 735 of themethod is performed; otherwise, step 740 of the method is performed.Because the initial value of K is 1 in the embodiment of the presentinvention, after one data block in the stripe is obtained, it may bedetermined whether the value of K is greater than D. If the value of Kis not greater than D, step 735 of the method is performed. If the valueof K is greater than D, it indicates that D data blocks in the stripehave been obtained, and step 740 of the method is performed.

In step 735, the storage device 110 sets K=K+1, and goes back to step705, so as to obtain a next data block in the stripe. In other words,the storage device 110 sets the value of the variable K to a value ofK+1, and goes back to step 705 to start to obtain the next data block inthe stripe circularly by using steps of the foregoing method, until alldata blocks in the stripe are obtained completely.

In step 740, the storage device 110 obtains P check blocks in the stripeaccording to the obtained D data blocks. For specific description ofthis step, reference may be made to related description of step 610 inFIG. 6.

In step 745, the storage device 110 writes the D data blocks into the Ddata disks, and writes the P check blocks into the P independent checkdisks. For specific description of this step, reference may be made torelated description of step 615 in FIG. 6.

In step 750, the storage device 110 determines whether a file that hasnot been completely written into a disk of the RAID exists. If a file inthe D files has not been completely written into a disk of the RAID, inother words, if the file has not been stored completely in the RAID, goback to step 705 of the method. The storage device 110 continues todetermine a sequence number of a check block in the next stripe, andobtain data blocks in the next stripe, so as to write data blocks andthe check block in the next stripe into the disks that form the RAID. Ifin step 750, the storage device 110 determines that all files that areto be stored in the RAID have been stored in the RAID completely, step755 of the method is performed to end this storage procedure.

FIG. 6 and FIG. 7 introduce a method for storing multiple files in aRAID with an independent check disk. By using the file processing methodshown in FIG. 6 or FIG. 7, after a file is stored in the RAID, one filemay be stored in one disk of the RAID. A specific storage structure maybe shown in FIG. 6B.

It can be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for description of somesteps of the embodiment in FIG. 7, reference may be made to specificdescription of a corresponding process in the embodiment shown in FIG.6. In addition, the file processing methods described in FIG. 6 and FIG.7 are based on same invention conception with the file processingmethods described in FIG. 3 and FIG. 5. In the foregoing embodiments,the description of each of the embodiments has respective focuses. For apart that is not described in detail in a certain embodiment, referencemay be made to related descriptions in other embodiments. By using thefile processing method described in the foregoing embodiments, datablocks of one file can be stored in one disk of the RAID. In addition,the storage device 110 writes a stripe, which includes data blocks ofdifferent files, into a disk. When a data block of a stripe is damaged,the storage device 110 can restore the damaged data block according to acheck block in the stripe and data blocks of other files in the stripe,thereby ensuring security of file storage.

In the embodiment of the present invention, by using the forgoing fileprocessing method shown in FIG. 3, FIG. 5, FIG. 6, or FIG. 7, after afile is stored in the RAID, in an archiving scenario, the stored file isless frequently accessed. Therefore, in order to achieve a purpose ofenergy-saving, a disk is generally in a sleeping or power-off state.When the file needs to be read, the method described in FIG. 8 may beused for reading. The following describes FIG. 8 with reference to FIG.1 and FIG. 2. The method includes:

In step 800, the storage device 110 receives an access request of thehost 100, where the access request is used to read a file stored in theRAID, and the access request carries a logical address of the file thatneeds to be accessed. It can be understood that the access request mayalso carry a file name of the to-be-accessed file.

In step 805, the storage device 110 queries, according to the logicaladdress, a physical address in which a data block of the file is stored.Generally, after data is stored by the storage device 110, a mappingtable of a mapping relationship between the physical address and thelogical address for storing data is constructed. After receiving theaccess request for reading a file, the storage device 110 may search, inthe mapping table, the physical address of the data in the diskaccording to the logical address carried in the access request. It canbe understood that in the RAID, a mapping table may be constructed bothfor data in the cache 120 and for data in the disk 130. When a physicaladdress is searched, generally, the mapping table of the cache 120 maybe first searched and then the mapping table of the disk 130 issearched. If data is in the cache, the data in the cache is directlyreturned to the host.

In step 810, the storage device 110 determines, according to thephysical address, one disk for storing the file. In the embodiment ofthe present invention, after files are stored, by using the fileprocessing method in the foregoing embodiments, in disks that form aRAID, one file can be stored in one disk. Therefore, in this step, thestorage device 110 can determine, according to a physical address, onedisk for storing the file.

In step 815, the storage device 110 returns data blocks of the filestored in the disk to the host 100. By using the foregoing fileprocessing method in the embodiment of the present invention, one filecan be stored in one disk. Therefore, when a stored file is read, thestorage device 110 may, according to the physical address, wake up adisk 130 in which the file is stored, or power on the disk 130, andreturn, to the host 100, data blocks that is of the file and stored inthe disk 130. Specifically, the storage device 110 may read data in thedisk 130 according to the obtained physical address, and return the datato the host 100.

In the embodiment of the present invention, because files are storedaccording to the method shown in FIG. 3, FIG. 5, FIG. 6, or FIG. 7, databelonging to one file is stored in one disk. Therefore, when a file isread, only one disk in which the file is stored needs to be waken up orpowered on, and data of the file is read from the disk and returned tothe host, with no need to wake up or power on all disks of the RAID,resulting in a significant effect of energy saving.

The embodiment of the present invention further provides a computerprogram product for data processing, including a computer readablestorage medium stored with program code, where an instruction includedin the program code is used to execute the method process described inany one of the foregoing method embodiments. A person of ordinary skillin the art may understand that the foregoing storage medium may includeany non-transitory machine-readable medium capable of storing programcode, such as a USB flash drive, a removable hard disk, a magnetic disk,an optical disc, a random-access memory (RAM), a solid state disk (SSD),or a non-volatile memory.

A person skilled in the art may understand that, in the embodiment ofthe present invention, a disk for storing metadata and the cache 120always remain in a power-on state, so as to make a timely response to anaccess request of the host. A person skilled in the art may know thatthe metadata is data that describes data stored in a RAID and anenvironment of the data, for example, the metadata may include a mappingrelationship between a logical address and a physical address.

Because frequent power-on or power-off of a disk may affect the effectof energy saving of a storage system, and may also affect a life time ofthe disk. To avoid a disk from being frequently powered on or poweredoff, disks may be graded in an actual application. A small quantity ofhigh-performance disks keep in a power-on state all the time, while alarge quantity of high-capacity disks enter an energy saving state. Ahigh-performance disk herein refers to a disk with a relatively lowaccess delay or a disk with many input/output operations per second(IOPS), for example a solid state disk (SSD). A high-capacity diskrefers to a disk with a relatively large capacity. After storage,according to a file access condition, a file with high access frequencymay be moved to the small quantity of reserved high-performance disksthat keep in a power-on state all the time, so as to reduce the numberof times that a disk is powered on or waken up, and improve a responsespeed.

Further, to avoid that a disk is frequently powered on or powered off,the storage system in the embodiment of the present invention may alsoprovide a warning mechanism and a protection mechanism. Statistics arecollected on the number of accumulated times that each disk in the RAIDis powered on and powered off. When the number of times that a certaindisk is powered on and powered off within a preset period of timeexceeds a preset threshold, the system provides a prompt or a warning,and may take some protection measures. A set threshold, for example, maybe 10 times/day or 100 times/month. A protection measure may be set asperforming no power-on or power-off operation on the disk in a setperiod of time, and so on, which is not limited herein.

Finally, it should be noted that the foregoing embodiments are merelyintended for describing the technical solutions of the presentinvention, rather than limiting the present invention.

What is claimed is:
 1. A file processing method performed by a storagedevice for storing a file in a redundant array of independent disks(RAID), comprising: receiving T files that are to be stored in the RAID,wherein a value of the T is no less than 3, and the value of the T isequal to the number of disks that form the RAID; determining a sequencenumber of a check block in a stripe of the RAID; repeatedly obtaining adata block, to be written into a disk, of the K^(th) file in the T filesas the K^(th) data block in the stripe, wherein a value of Kprogressively increases from 1 to T, and the value of K is not equal tothe sequence number of the check block in the stripe; computing thecheck block in the stripe according to data blocks in the stripe; andwriting, into the T disks, the data blocks in the stripe and theobtained check block in the stripe, wherein each block is written intoone disk.
 2. The file processing method according to claim 1, furthercomprising: when the K^(th) file has no data block to be written intothe RAID, determining whether other files except the T files arereceived; if the other files are received, selecting a file from thereceived other files; and using a data block, to be written into a disk,in the selected file as the K^(th) data block in the stripe.
 3. The fileprocessing method according to claim 1, further comprising: when theK^(th) file has no data block to be written into a disk, if other filesexcept the T files are not received, filling the K^(th) data block inthe stripe with 0s.
 4. A method performed by a storage device forstoring a file in a redundant array of independent disks RAID, whereinthe RAID comprises D data disks and P independent check disks, a valueof the D is no less than 2, and a value of the P is no less than 1; andthe method comprises: receiving D files that are to be stored in theRAID; repeatedly obtaining a data block, to be written into a data disk,of the K^(th) file in the D files as a data block that is in a stripe ofthe RAID and is to be stored in the K^(th) data disk, wherein a value ofK progressively increases from 1 to D; computing P check blocks in thestripe according to the obtained D data blocks; and writing the D datablocks into the D data disks, and writing the P check blocks into the Pindependent check disks, wherein each block is written into one disk. 5.The method according to claim 4, further comprising: when the K^(th)file has no data block to be written into a data disk, determiningwhether other files except the D files are received; if the other filesare received, selecting a file from the received other files; and usinga data block, to be written into a disk, in the selected file as a datablock that is in the stripe and is to be stored in the K^(th) data disk.6. The method according to claim 4, further comprising: when the K^(th)file has no data block to be written into a data disk, if other filesexcept the D files are not received, filling the data block that is inthe stripe and is to be stored in the K^(th) data disk with 0s.
 7. Astorage device, comprising: a redundant array of independent disks RAID,configured to store a file, and the RAID comprises T disks, wherein avalue of the T is no less than 3; a communication interface, configuredto communicate with a host and the RAID; and a processor, configured toreceive T files that are to be stored in the RAID; determine a sequencenumber of a check block in a stripe of the RAID; repeatedly obtain adata block, to be written into a disk, of the K^(th) file in the T filesas the K^(th) data block in the stripe, wherein a value of Kprogressively increases from 1 to T, and the value of K is not equal tothe sequence number of the check block in the stripe; compute the checkblock in the stripe according to data blocks in the stripe; and write,into the T disks, the data blocks in the stripe and the obtained checkblock in the stripe, wherein each block is written into one disk.
 8. Thestorage device according to claim 7, wherein the processor is furtherconfigured to: when the K^(th) file has no data block to be written intoa disk, determine whether other files except the T files are received;if the other files are received, select a file from the received otherfiles; and use a data block, to be written into a disk, in the selectedfile as the K^(th) data block in the stripe.
 9. The storage deviceaccording to claim 7, wherein the processor is further configured to:when the K^(th) file has no data block to be written into a disk, ifother files except the T files are not received, fill the K^(th) datablock in the stripe with 0s.
 10. A storage device, comprising: aredundant array of independent disks RAID, configured to store a file,wherein the RAID comprises D data disks and P independent check disks, avalue of the D is no less than 2, and a value of the P is no less than1; a communication interface, configured to communicate with a host andthe RAID; and a processor, configured to receive D files that are to bestored in the RAID; repeatedly obtain a data block, to be written into adata disk, of the K^(th) file in the D files as a data block that is ina stripe of the RAID and is to be stored in the K^(th) data disk,wherein a value of K progressively increases from 1 to D; compute Pcheck blocks in the stripe according to the obtained D data blocks; andwrite the D data blocks into the D data disks, and write the P checkblocks into the P independent check disks, wherein each block is writteninto one disk.
 11. The storage device according to claim 10, wherein theprocessor is further configured to: when the K^(th) file has no datablock to be written into a data disk, determine whether other filesexcept the D files are received; if the other files are received, selecta file from the received other files; and use a data block, to bewritten into a disk, in the selected file as a data block that is in thestripe and is to be stored in the K^(th) data disk.
 12. The storagedevice according to claim 10, wherein the processor is furtherconfigured to: when the K^(th) file has no data block to be written intoa data disk, if other files except the D files are not received, fillthe data block that is in the stripe and is to be stored in the K^(th)data disk with 0s.